package com.dream.keigezhushou.Activity.view;

import android.content.Context;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingParent;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;

/**
 * 自定义滚动
 */

public class NestedScrollViewBottom extends NestedScrollView implements NestedScrollingParent,NestedScrollingChild {

    private ScrollBottomListener scrollBottomListener;

    public NestedScrollViewBottom(Context context) {
        super(context);
    }

    public NestedScrollViewBottom(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NestedScrollViewBottom(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt){
        if(t + getHeight() >=  computeVerticalScrollRange()){
            //ScrollView滑动到底部了
            scrollBottomListener.scrollBottom();
        }
    }

    public void setScrollBottomListener(ScrollBottomListener scrollBottomListener){
        this.scrollBottomListener = scrollBottomListener;
    }

    public interface ScrollBottomListener{
        public void scrollBottom();
    }


}
